using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BLL;
using DTO;

namespace QLSV
{
    public partial class ThemDSSV : Form
    {
        SINHVIEN sv = new SINHVIEN();
        SinhvienDAL svdal = new SinhvienDAL();
        public ThemDSSV()
        {
            InitializeComponent();
            lblThongbao.Text = "Nhap ma cua sinh vien can them , roi nhap nut Them";
            btnThem.Enabled = true; 
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            try
            {
                bool sv = svdal.InsertSINHVIEN(txtMaSV.Text, txtTenSV.Text, txtHolot.Text);
                if (sv)
                {
                    lblThongbao.Text = "Them thanh cong";
                    btnThem.Enabled = false;
                    btnUndo.Enabled = true;

                }
                else
                    lblThongbao.Text = "Them that bai";
            }
            catch
            {
                lblThongbao.Text = "Them that bai";
                btnUndo.Enabled = true;
            }
        }

        private void btnUndo_Click(object sender, EventArgs e)
        {
            lblThongbao.Text = "Nhap ma cua mon hoc can thay doi thong tin, roi nhap nut Them";
            txtTenSV.Text = "";
            txtMaSV.Text = "";
            txtHolot.Text = "";
            btnThem.Enabled = true;
            btnUndo.Enabled = false;
        }
    }
}